﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Reflection;

namespace Algorithms
{
    public class Program
    {
        public static void Main(string[] args)
        {
            PrintHeader();

            CommandInteperator cmdIntp = new CommandInteperator();
            dynamic results = cmdIntp.Analysis(args);

            if (results is ContentResult)
                PrintContent(results);
            else if (results is ErrorResult)
                PrintError(results);
            else if (results is AnalyzeStrategyResult)
                PrintAnalyzeResult(results);
        }

        public static void PrintHeader()
        {
            Console.WriteLine();
            ApplicationInfo appInfo = ApplicationInfo.GetInstance();
            Console.WriteLine("{0}, {1}", appInfo.Name, appInfo.Version);
            Console.WriteLine(appInfo.SubTitle);
            Console.WriteLine();
        }

        public static void PrintContent(ContentResult results)
        {
            Console.Write(results.Content);
        }

        public static void PrintError(ErrorResult results)
        {
            Console.WriteLine("Application Error:");
            Console.Write(results.Message);
        }

        public static void PrintAnalyzeResult(AnalyzeStrategyResult results)
        {
            Console.Write(string.Format("{0}: {1}, {2}", results.StrategyName, results.Successful ? "Successful" : "Failed", results.Message));
        }
    }
}
